home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12834 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  53 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.athene.co.uk!not-for-mail
  3. From: "C.J. Scaife" <JOLTSWIFT@Athene.co.uk>
  4. Subject: Re: Help with calling batch files from Borland C++
  5. Message-ID: <3151DBDB.266B@Athene.co.uk>
  6. Date: Thu, 21 Mar 1996 22:44:43 +0000
  7. References: <ragnaroek1996Mar20.184656.11284@news2.compulink.com>
  8. Organization: JoltSwift Ltd.
  9. X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
  10. MIME-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13.  
  14. Chantal Marier wrote:
  15. > I am hoping that someone will be able to help me with a program that I have
  16. > made.  It almost works except for the fact that it only reads the batch file in
  17. > question instead of calling the batch file.  I am using Borland C++ and my
  18. > program follows.
  19. > #include <stdio.h>
  20. >         FILE *filePtr;                                  /* Defines a file
  21. > pointer */
  22. > main()
  23. > {
  24. >         filePtr = fopen("menu.bat", "r");               /* Opens file for
  25. > reading */
  26. >         if (filePtr == NULL)
  27. >                 { printf("Error opening file.\n"); }    /* Displays error
  28. > message if                                                      file does not
  29. > open */
  30. >         else
  31. >         { fclose(filePtr);                              /* Closes file */
  32. >                 printf("Program complete.\n"); }
  33. > return 0;
  34. > }
  35. > If anyone out there knows how to do what I need to do, please, PLEASE let me
  36. > know how to do this darn program.  I am just learning how to program and your
  37. > help would be greatly appreciated.  :)
  38.  
  39. Dos batch files are interpreted by the command line interpreter 
  40. Command.Com. You should look at the system() function in your standard 
  41. library documentation and you will find it does what you want and also 
  42. works on unix systems etc...
  43. -- 
  44. Written by Chris Scaife.
  45. For more details see my home page: 
  46. http://www.Athene.co.uk/Joltswift/P1.htm
  47.  
  48.